package netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;
import netty.http.handler.TestHttpServerHandler;

/**
 * @ClassName TestServerInitializer
 * @Description TODO
 * @Author director吴
 * @Date 2022/2/16 13:06
 * @Version 1.0
 **/
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道加入处理器
        //获取管道
        ChannelPipeline pipeline = ch.pipeline();

        //加入Netty提供的HTTPServerCodec  codec =>[编解码器]
        pipeline.addLast("MyHttpServerCodec",new HttpServerCodec());

        //增加一个自定义的Handler
        pipeline.addLast("MyTestHttpServerHandler",new TestHttpServerHandler());


    }
}
